//
//  BaseNavViewController.swift
//  SinaBlog
//
//  Created by macs on 15/11/16.
//  Copyright © 2015年 BlackTail. All rights reserved.
//

import UIKit

class BaseNavViewController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        if self.childViewControllers.count > 0 {
            //设置左上角返回按钮及其点击方法
           viewController.navigationItem.backBarButtonItem = UIBarButtonItem(title: "返回", style: .Plain, target: self, action: "backDidClick")
    
        }
        
        super.pushViewController(viewController, animated: animated)
    }

    @objc private func backDidClick () {
        
        self.popViewControllerAnimated(true)
        
    }
    
}
